package com.gzc.pm.util
{
	import com.gzc.pm.bean.CollectionBean;
	import com.gzc.pm.dao.CollectionDao;
	
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	import mx.rpc.events.ResultEvent;

	public class TempUtil
	{
		public function TempUtil()
		{
			_dao = new CollectionDao();
		}
		
		private var _dao:CollectionDao;
		
		public function generateData():void{
			var timer:Timer = new Timer(5000);
			timer.addEventListener(TimerEvent.TIMER, onTimer);
			timer.start();
		}
		private function onTimer(e:TimerEvent):void{
			add();
		}
		
		public function add():void{
			var bean:CollectionBean = new CollectionBean();
			bean.logId = String(int(Math.random()*95555+4));
			bean.equId = Math.random()>0.7?'Baa0':'Bab0';
			bean.dataType = Math.random()>0.95?'1':'2';
			var date:Date = new Date();
			var y:String = String(date.fullYear);
			var m:String = date.month<9?'0'+String(date.month+1):String(date.month+1);
			var d:String = date.date<10?'0'+String(date.date):String(date.date);
			var h:String = date.hours<10?'0'+String(date.hours):String(date.hours);
			var m1:String = date.minutes<10?'0'+String(date.minutes):String(date.minutes);
			var s:String = date.seconds<10?'0'+String(date.seconds):String(date.seconds);
			bean.testDate = y+m+d+h+m1+s;
			bean.productId = y+String(int(Math.random()*7777777777+1));
			bean.v1 = (Math.random()*80.00+20.00).toFixed(2);
			bean.v2 = (Math.random()*80.00+20.00).toFixed(2);
			bean.v3 = (Math.random()*80.00+20.00).toFixed(2);
			bean.v4 = (Math.random()*80.00+20.00).toFixed(2);
			bean.v5 = (Math.random()*80.00+20.00).toFixed(2);
			bean.v6 = (Math.random()*80.00+20.00).toFixed(2);
			bean.v7 = (Math.random()*80.00+20.00).toFixed(2);
			bean.v8 = (Math.random()*80.00+20.00).toFixed(2);
			bean.v9 = (Math.random()*80.00+20.00).toFixed(2);
			bean.v10 = (Math.random()*80.00+20.00).toFixed(2);
			bean.v11 = (Math.random()*80.00+20.00).toFixed(2);
			bean.v12 = (Math.random()*80.00+20.00).toFixed(2);
			bean.v13 = (Math.random()*80.00+20.00).toFixed(2);
			bean.v14 = (Math.random()*80.00+20.00).toFixed(2);
			bean.v15 = (Math.random()*80.00+20.00).toFixed(2);
			bean.v16 = (Math.random()*80.00+20.00).toFixed(2);
			bean.v17 = (Math.random()*80.00+20.00).toFixed(2);
			bean.state = '0';
			
			_dao.insert(bean, function(e:ResultEvent):void{}); 
		}
		
	}
}